;(function(){
	wlxer = {
		init:function(){
			var self = this;
			//tableChang
			self.tableChang();
			//下拉的时间区间选择
			self.selectTime();
			//跳转到运输量明细页面transportDetail.html
			self.transportDetail();
			//点击自定义
			self.freedomDefined();
		
		 	// 选择日期时间
			self.selectDateTime();
		},
		tableChang:function(){
			$('.changTime').on('touchend',function(){
				if(!$(this).hasClass('activeTime')){
					$(this).addClass('activeTime');
					$(this).siblings().removeClass('activeTime');
				}
			});
		},
		selectTime:function(){
			$('.selectTimeBox').on('touchstart',function(ev){
				$('.selectTimeWrap').hasClass('f-dn')?$('.selectTimeWrap').removeClass('f-dn'):$('.selectTimeWrap').addClass('f-dn');
				ev.stopPropagation();
				ev.preventDefault();
			})
			$('.totalData,.imgTable').on('touchstart',function(){
				$('.selectTimeWrap').addClass('f-dn');
				$('.navItem2').find('.timeWrap').addClass('f-dn');
				$('#searchBtn').addClass('f-dn');
			})
			$('.selectTimeCont .time').on('touchstart',function(ev){
				var timeType = $(this).attr('data-time');
				switch(timeType){
					case "自定义":
						$('.page__navBox .navItem1').addClass('f-dn');
						$('.page__navBox .navItem2').removeClass('f-dn');
					break;
					default:
						$('.page__navBox .navItem1').removeClass('f-dn');
						$('.page__navBox .navItem2').addClass('f-dn');
						$('.page__navBox .navItem1 .prevTime').addClass('activeTime');
						$('.page__navBox .navItem1 .nextTime').removeClass('activeTime');
						$('.navItem2').find('.timeWrap').addClass('f-dn');
						$('.freeDomDefind').addClass('f-dn');
						switch(timeType){
							case "日":
								$('.page__navBox .navItem1 .prevTime').html('前一日');
								$('.page__navBox .navItem1 .nextTime').html('当日');
							break;
							case "周":
								$('.page__navBox .navItem1 .prevTime').html('前一周');
								$('.page__navBox .navItem1 .nextTime').html('本周');
								break;
							case "月":
								$('.page__navBox .navItem1 .prevTime').html('前一月');
								$('.page__navBox .navItem1 .nextTime').html('本月');
								break;
							case "年":
								$('.page__navBox .navItem1 .prevTime').html('前一年');
								$('.page__navBox .navItem1 .nextTime').html('今年');
								break;
						}
					break;

				}
				$('.selectTimeWrap').addClass('f-dn');
				ev.stopPropagation();
				ev.preventDefault();
			});
		},
		transportDetail:function(){
			$('[data-to=transportDetail]').on('touchend',function(ev){
				window.location.href = "transportDetail.html";
				ev.stopPropagation();
				ev.preventDefault();
			});
		},
		freedomDefined:function(){
			$('.navItem2 .navItem_item').on('touchstart',function(ev){
				$('.selectTimeWrap').addClass('f-dn');
				$(this).parent('.navItem2').find('.timeWrap').removeClass('f-dn');
				ev.stopPropagation();
				ev.preventDefault();
			})
		},
		/**
		 * 选择日期时间
		 * */
		selectDateTime:function(){
			$('.timeWrap').on('touchstart','.startTime,.endTime',function(ev){
				$(this).datetimePicker({
					min:'2000-01-01',
					max:'2050-12-31',
					times:function(){
						return;
					}
				});
			})
		},
	}
})()

$(function(){
	wlxer.init();
});